<template>
  <div>
    <el-container>
      <!--   侧边栏   -->
      <el-aside :width="asideWidth" style="min-height: 100vh; background-color: #001529">
        <div style="height: 60px; color: white; display: flex; align-items: center; justify-content: center">
          <img src="@/assets/logo3.png" alt="" style="width: 40px; height: 40px">
        </div>
        <el-menu :class="isCollapseClass" :collapse-transition="false" :collapse="isCollapse" style="border: none"
                 background-color="#001529" text-color="rgba(255, 255, 255, 0.65)" active-text-color="#fff"
                 :default-active="$route.path">
          <el-menu-item index="/">
            <i class="el-icon-house"></i>
            <span slot="title">系统首页</span>
          </el-menu-item>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">2级菜单</span>
            </template>
            <el-menu-item index="2-1">Element页面</el-menu-item>
            <el-menu-item index="2-2">2-2级菜单</el-menu-item>
            <el-menu-item index="2-3">2-3级菜单</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">3级菜单</span>
            </template>
            <el-menu-item index="3-1">3-1</el-menu-item>
            <el-menu-item index="3-2">3-2</el-menu-item>
            <el-menu-item index="3-3">3-3级菜单</el-menu-item>
          </el-submenu>
          <el-menu-item index="4">
            <i class="el-icon-menu"></i>
            <span slot="title">4级菜单</span>
          </el-menu-item>
          <el-menu-item index="5">
            <i class="el-icon-menu"></i>
            <span slot="title">5级菜单</span>
          </el-menu-item>

        </el-menu>
      </el-aside>
      <el-container>
        <!--     头部     -->
        <el-header>
          <i :class="collapseIcon" style="width: 24px; font-size: 24px" @click="handleCollapse"></i>
          <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 30px">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item :to="{ path: '/user' }">用户管理</el-breadcrumb-item>
          </el-breadcrumb>
          <div style="flex: 1; width: 0; height: 100%; display: flex; align-items: center; justify-content: flex-end">
            <i class="el-icon-shengdanxuehua" @click="handleFull" style="font-size: 24px; margin: 0 7px"></i>
            <el-dropdown placement="bottom">
              <div style="display: flex; align-items: center; cursor: default;">
                <img src="@/assets/logo2.png" alt="" style="width: 30px;">
                <span>管理员</span>
              </div>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>个人信息</el-dropdown-item>
                <el-dropdown-item>修改密码</el-dropdown-item>
                <el-dropdown-item @click.native="$router.push('/login')">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>
        <!--    主体    -->
        <el-main>
          <div
              style="box-shadow: 0 0 10px rgba(0, 0, 0, .1); padding: 10px 20px; border-radius: 5px; margin-bottom: 10px">
            早安，祝你开心快乐每一天！
          </div>
          <div style="display: flex">
            <el-card style="width: 50%; margin-right: 10px">
              <div slot="header" class="clearfix">
                <span>我的第一个vue项目</span>
              </div>
              <div>
                第一个项目的vue部分已经结束！
                <div style="margin-top: 20px">
                  <div style="margin: 10px 0"><strong>主题色</strong></div>
                  <el-button type="primary">按钮</el-button>
                  <el-button type="success">按钮</el-button>
                  <el-button type="warning">按钮</el-button>
                  <el-button type="danger">按钮</el-button>
                  <el-button type="info">按钮</el-button>
                </div>
              </div>
            </el-card>
            <el-card style="width: 50%">
              <div slot="header" class="clearfix">
                <span>渲染用户的数据</span>
              </div>
              <div>
                <el-table :data="users">
                  <el-table-column label="ID" prop="id"></el-table-column>
                  <el-table-column label="用户名" prop="username"></el-table-column>
                  <el-table-column label="姓名" prop="name"></el-table-column>
                  <el-table-column label="地址" prop="address"></el-table-column>
                </el-table>
              </div>
            </el-card>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>

import request from "@/utils/request";

export default {
  name: 'HomeView',
  data() {
    return {
      isCollapse: false,  //不收缩
      asideWidth: "200px",
      isCollapseClass: "",
      collapseIcon: "el-icon-s-fold",
      users: []
    }
  },
  mounted() {
    // axios.get('http://localhost:8090/user/selectAll').then( res => {
    //   console.log(res.data) //后台返回的数据
    //   this.users = res.data.data;
    // })
    request.get('/user/selectAll').then(res => {
      this.users = res.data;
    })
  },
  methods: {
    handleCollapse() {
      this.isCollapse = !this.isCollapse
      this.asideWidth = this.isCollapse ? '64px' : '200px'
      this.isCollapseClass = this.isCollapse ? 'el_submenu_title' : ''
      this.collapseIcon = this.isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'
    },
    handleFull() {
      document.documentElement.requestFullscreen();
    }
  }
}
</script>

<style>
.el-menu--inline {
  background-color: #000c17 !important;
}

.el-submenu {
  min-width: 0 !important;
}

.el-aside {
  transition: width .3s;
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
}

.el-header {
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
  display: flex;
  align-items: center;
}

.el-menu--inline .el-menu-item {
  background-color: #000c17 !important;
  padding-left: 49px !important;
}

.el-menu-item:hover, .el-menu-item:hover i, .el-submenu__title:hover span, .el-submenu__title:hover i {
  color: #fff !important;
}

.el-menu-item.is-active {
  background-color: #1890ff !important;
  margin: 4px !important;
  border-radius: 5px !important;
}

.el-menu-item {
  min-width: 0 !important;
  margin: 4px !important;
  height: 40px !important;
  line-height: 40px !important;
}

.el-submenu__title {
  margin: 4px !important;
  height: 40px !important;
  line-height: 40px !important;
}

.el-tooltip {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.el_submenu_title {
  display: flex !important;
  flex-direction: column;
  align-items: center !important;
  justify-content: center !important;
}
</style>
